<!DOCTYPE html>
<html lang="zh-cn">

<head>

  <meta content="text/html;charset=utf-8" http-equiv="content-type">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">

  <title>滑雪族 - 提现申请</title>

  <!-- Bootstrap Core CSS -->
<!-- MetisMenu CSS -->
<!-- Custom CSS -->
<!-- Custom Fonts -->
  <!-- Timeline CSS -->
  <!-- Morris Charts CSS -->
  <!-- Bootstrap DateRangePicker CSS -->
  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->

    <link rel="stylesheet" href="/server/r/bower_components/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/server/r/bower_components/metisMenu/dist/metisMenu.min.css" />
    <link rel="stylesheet" href="/server/r/static/css/sb-admin-2_e507c2b.css" />
    <link rel="stylesheet" type="text/css" href="/server/r/bower_components/font-awesome/css/font-awesome.min.css" />
    <link type="text/css" rel="stylesheet" href="/server/r/static/css/hxz/common_2baa698.css" />
    <link rel="stylesheet" href="/server/r/static/css/timeline_1c13c9f.css" />
    <link rel="stylesheet" href="/server/r/bower_components/morrisjs/morris.css" />
    <link rel="stylesheet" type="text/css" href="/server/r/bower_components/alertify/themes/alertify.core.css" />
    <link rel="stylesheet" type="text/css" href="/server/r/bower_components/alertify/themes/alertify.bootstrap.css" />
    <link type="text/css" rel="stylesheet" href="/server/r/bower_components/select2/dist/css/select2.min.css" />
    <link rel="stylesheet" href="/server/r/bower_components/bootstrap-daterangepicker/daterangepicker.css" />
</head>

<body>
<div id="wrapper">

  <!-- Navigation -->
  <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">

    <div class="navbar-header">
  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
  </button>
  <a class="navbar-brand" href="activity-list">滑雪族 管理</a>
</div>
<!-- /.navbar-header -->

<ul class="nav navbar-top-links navbar-right">
  <!-- /.dropdown -->
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
      <i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
    </a>
    <ul class="dropdown-menu dropdown-user">
      <li><a href="/manage/logout"><i class="fa fa-sign-out fa-fw"></i> 退出系统</a>
      </li>
    </ul>
    <!-- /.dropdown-user -->
  </li>
  <!-- /.dropdown -->
</ul>
<!-- /.navbar-top-links -->

    <div class="navbar-default sidebar" role="navigation">
      <div class="sidebar-nav navbar-collapse">
        <ul class="nav" id="side-menu">
  <li>
    <a href="#"><i class="fa fa-asterisk fa-fw"></i> 产品管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/activity-list"> 产品查询</a>
      </li>
      <li>
        <a href="/manage/manage-organizer-render-activity"> 产品显示控制</a>
      </li>
    </ul>
    <!-- /.nav-second-level -->
  </li>
  <li>
    <a href="/#"><i class="fa fa-male fa-fw"></i> 报名管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/player-list"> 报名查询</a>
      </li>
    </ul>
  </li>
  <li>
    <a href="#"><i class="fa fa-list-alt fa-fw"></i> 订单管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/order-list"> 订单查询</a>
      </li>
      <li>
        <a href="/manage/refund-list"> 退款管理</a>
      </li>
    </ul>
    <!-- /.nav-second-level -->
  </li>
  <li>
    <a href="#"><i class="fa fa-check-circle fa-fw"></i> 主办方认证<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/organizer-edit"> 创建主办方</a>
      </li>
      <li>
        <a href="/manage/organizer-list"> 主办方列表</a>
      </li>
      <li>
        <a href="/manage/organizer-print"> 冬令营打印设置</a>
      </li>

    </ul>
    <!-- /.nav-second-level -->
  </li>
  <li>
    <a href="#"><i class="fa fa-picture-o fa-fw"></i> 雪场管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/ski-field-edit"> 创建雪场</a>
      </li>
      <li>
        <a href="/manage/ski-field-list"> 雪场列表</a>
      </li>

    </ul>
    <!-- /.nav-second-level -->
  </li>
  <li>
    <a href="#"><i class="fa fa-users fa-fw"></i> 教练管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/coach-list"> 预约情况</a>
      </li>
    </ul>
    <!-- /.nav-second-level -->
  </li>
  <li>
    <a href="#"><i class="fa fa-credit-card fa-fw"></i> 结算管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/manage-transfer-list"> 转账管理</a>
      </li>
      <li>
        <a href="/manage/manage-withdrawals-apply-list"> 提现申请</a>
      </li>
      <li>
        <a href="/manage/manage-withdrawals-record-list"> 结算列表</a>
      </li>
    </ul>
    <!-- /.nav-second-level -->
  </li>
  <li>
    <a href="#"><i class="fa fa-rmb fa-fw"></i> 财务管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/stream-list"> 交易流水</a>
      </li>
      <li>
        <a href="/manage/manage-bill-record-list"> 对账列表</a>
      </li>
    </ul>
    <!-- /.nav-second-level -->
  </li>
  <li>
    <a href="#"><i class="fa fa-dollar fa-fw"></i> 营销管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/marketing-list"> 返利管理</a>
      </li>
    </ul>
    <!-- /.nav-second-level -->
  </li>
  <li>
    <a href="#"><i class="fa fa-comments fa-fw"></i> 评价管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/comment-list">评价管理</a>
      </li>
    </ul>
  </li>
  <li>
    <a href="#"><i class="fa fa-tasks fa-fw"></i> 定时处理管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/quartz-list"> 定时处理列表</a>
      </li>
    </ul>
    <!-- /.nav-second-level -->
  </li>
  <li>
    <a href="#"><i class="fa fa-wechat fa-fw"></i> 微信页面管理<span class="fa arrow"></span></a>
    <ul class="nav nav-second-level">
      <li>
        <a href="/manage/typography-list"> 微信首页管理</a>
      </li>
      <li>
        <a href="/manage/activity-weight-manage"> 活动置顶</a>
      </li>
    </ul>
    <!-- /.nav-second-level -->
  </li>
</ul>
      </div>
      <!-- /.sidebar-collapse -->
    </div>
    <!-- /.navbar-static-side -->
  </nav>

  <!--提现记录详情的模态窗口-->
  <div class="modal fade" id="withdrawals-record-dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
       aria-hidden="true">
    <div class="modal-dialog" style="width: 70%;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h5 class="modal-title">
            <span>提现记录</span>
            <a style="float: right; margin-right: 15px;" data-code="" type="button" class="btn btn-info btn-xs  btn-outline withdrawals-orders">查看相关订单</a>
          </h5>
        </div>
        <div class="modal-body">
          <div class="row">
            <table class="table table-bordered table-striped">
              <thead>
              <tr class="warning">
                <th>序号</th>
                <th>提现金额</th>
                <th>活动ID</th>
                <th>活动名称</th>
                <th>场次ID</th>
                <th>场次名称</th>
                <th>已报名人数</th>
                <th>报名截止时间</th>
                <th>场次状态</th>
              </tr>
              </thead>
              <tbody id="applyDetail-list-body"></tbody>
            </table>
          </div>
          <!--<div class="row">-->
          <!--<label class="pull-right">本次操作共提现金额：<span id="cash">4000元</span></label>-->
          <!--</div>-->
        </div>
      </div>
      <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
  </div>

  <!-- 提现相关订单模态窗口 -->
  <div class="modal fade" id="withdrawals-orders-dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
       aria-hidden="true">
    <div class="modal-dialog" style="width: 70%;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h5 class="modal-title">
            <span>相关订单</span>
            <a style="float: right; margin-right: 15px;" data-code="" type="button" class="btn btn-info btn-xs  btn-outline withdrawals-excel">下载excel表格</a>
          </h5>
        </div>
        <div class="modal-body">
          <div class="row">
            <table class="table table-bordered table-striped">
              <thead>
              <tr class="warning">
                <th>订单ID</th>
                <th>订单号</th>
                <th>下单用户</th>
                <th>支付时间</th>
                <th>产品</th>
                <th>子项目</th>
                <th>提现数量</th>
                <th>提现金额</th>
              </tr>
              </thead>
              <tbody id="applyOrders-list-body"></tbody>
            </table>
            <div class="pagination dataTables_paginate paging_simple_numbers pull-right" id="pagination-orders" role="status" aria-live="polite"></div>
          </div>

        </div>
      </div>
      <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
  </div>

  <!--拒绝申请的模态窗口-->
  <div class="modal fade" id="reject-dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
       aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h5 class="modal-title">拒绝申请</h5>
          <input id="reject-applyId" type="hidden">
        </div>
        <div class="modal-body">
          <div class="form-group">
            <label>原因：</label>
          </div>
          <div class="form-group">
            <textarea rows="10" cols="80" style="resize:none;" id="reject-reason"></textarea>
          </div>
          <div class="form-group">
            <a type="button" id="reject-submit" class="btn btn-sm btn-success btn-outline">确定</a>
          </div>
        </div>
        <!--<div class="row">-->
        <!--<a type="button" id="withdrawals-submit" class="btn btn-sm btn-success btn-outline">确定</a>-->
        <!--</div>-->
      </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>


<div id="page-wrapper">
  <div class="row">
    <div class="col-lg-12">
      <h3 class="page-header">提现申请</h3>
    </div>
    <!-- /.col-lg-12 -->
  </div>
  <!-- /.row -->
  <div class="form-inline">
    <div class="form-group">
      <label>申请时间：</label>

      <div class="input-group" id="start-date">
          <span class="input-group-addon">
            <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
          </span>
        <input type="text" class="form-control input-sm" readonly placeholder="请选择查询区间起点" style="width: 150px;">
      </div>
      <label> ~ </label>

      <div class="input-group" id="end-date">
          <span class="input-group-addon">
            <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
          </span>
        <input type="text" class="form-control input-sm" readonly placeholder="请选择查询区间终点" style="width: 150px;">
      </div>
    </div>
    <input type="hidden" id="start-time" name="startTime">
    <input type="hidden" id="end-time" name="endTime">


  </div>
  <div class="form-inline">
    <div class="form-group">
      <label>主办方：&nbsp;&nbsp;&nbsp;</label>
      <select class="form-control" id="withdrawals-organizer"></select>
    </div>
    <div class="form-group">
      <label>状态：</label>
      <select class="form-control" id="withdrawals-status"></select>
    </div>
    <div class="form-group">
      <a id="withdrawals-filter" type="button" class="btn btn-sm btn-success btn-outline">查询</a>
    </div>
  </div>
  <div class="row">
    <div class="col-lg-12">
      <div class="panel panel-default">
        <div class="panel-heading">
          提现申请列表
        </div>
        <!-- /.panel-heading -->
        <div class="panel-body">
          <div class="dataTable_wrapper">
            <table class="table table-striped table-bordered table-hover">
              <thead>
              <tr class="warning">
                <th>序号</th>
                <th>主办方</th>
                <th>联系方式</th>
                <th>提现金额</th>
                <th>申请时间</th>
                <th>处理时间</th>
                <th>状态</th>
                <th>操作</th>
              </tr>
              </thead>
              <tbody id="withdrawals-list-body"></tbody>
            </table>
          </div>

          <!-- /.row -->
          <div class="pagination dataTables_paginate paging_simple_numbers pull-right" id="pagination" role="status"
               aria-live="polite">
          </div>
        </div>
        <!-- /.panel-body -->
      </div>
      <!-- /.panel -->
    </div>
    <!-- /.col-lg-12 -->
  </div>
</div>
<!-- /#page-wrapper -->

<!-- /#wrapper --><script id="tpl-withdrawals-list-item" type="text/template">
  <tr>
    <td>{{index}}</td>
    <td>{{organizer.name}}</td>
    <td>{{organizer.phone}}</td>
    <td>{{withdrawalsAccount}}元</td>
    <td>{{datetime(applyTime)}}</td>
    <% if (status ==0 ) { %>
    <td></td>
    <% } else if(status ==3){%>
    <td></td>
    <% }else{ %>
    <td>{{datetime(processingTime)}}</td>
    <% } %>
    <td>{{withdrawalStatus(status)}}</td>
    <td>
      <% if (status == 0) { %>
      <a href="/manage/settlement/detail?applyId={{applyId}}" type="button"
         class="btn btn-success btn-xs  btn-outline handler-withdrawals">申请处理</a>
      <% } %>
      <% if (status == 3) { %>
      <a href="/manage/settlement/detail?applyId={{applyId}}" type="button"
         class="btn btn-success btn-xs  btn-outline handler-withdrawals">申请处理</a>
      <% } %>
      <a data-code="{{applyId}}" type="button" class="btn btn-success btn-xs  btn-outline detail-withdrawals">提现详情</a>
      <% if (status == 0) { %>
      <a data-code="{{applyId}}" type="button" class="btn btn-danger btn-xs  btn-outline reject-apply">拒绝申请</a>
      <% } %>
      <% if (status == 3) { %>
      <a data-code="{{applyId}}" type="button" class="btn btn-danger btn-xs  btn-outline reject-apply">拒绝申请</a>
      <% } %>
      <a data-code="{{applyId}}" type="button" class="btn btn-success btn-xs  btn-outline apply-excel">下载申请表</a>
    </td>
  </tr>
</script>

<script id="tpl-apply-detail-list-item" type="text/template">
  <tr>
    <td>{{applyDetailId}}</td>
    <td>{{withdrawalsAccount}}元</td>
    <td>{{episode.activityId}}</td>
    <td>{{episode.name}}</td>
    <td>{{episodeId}}</td>
    <td>{{episode.episodeName}}</td>
    <td>{{episode.playerCount}}人</td>
    <td>{{datetime(episode.registerDeadline)}}</td>
    <td>{{episodeStatus(episode.status)}}</td>
  </tr>
</script>
<script id="tpl-apply-order-list-item" type="text/template">
  <tr>
    <td>{{order_id}}</td>
    <td>{{code}}</td>
    <td>{{name}}</td>
    <td>{{datetime(pay_time)}}</td>
    <td>{{title}}</td>
    <td>{{charge_name}}</td>
    <td>{{charge_num}}</td>
    <td>{{pay_price}}</td>
  </tr>
</script>
<div id="hxz-background" class="background" style="display: none; "></div>
<div id="hxz-progressBar" class="progressBar" style="display: none; ">数据加载中，请稍等...</div>

<script src="/server/r/require.js"></script>
<script>/*resourcemap*/
require.config({paths:{
  "r/bower_components/jquery/dist/jquery.min": "/server/r/bower_components/jquery/dist/jquery.min",
  "r/bower_components/underscore/underscore-min": "/server/r/bower_components/underscore/underscore-min",
  "r/static/js/hxz/hxz.valid": "/server/r/static/js/hxz/hxz.valid_12cc206",
  "r/static/js/hxz/hxz.rest": "/server/r/static/js/hxz/hxz.rest_07c8105",
  "r/bower_components/alertify/alertify.min": "/server/r/bower_components/alertify/alertify.min",
  "r/static/js/alertify-config": "/server/r/static/js/alertify-config_0cc8db2",
  "r/bower_components/bootstrap/dist/js/bootstrap.min": "/server/r/bower_components/bootstrap/dist/js/bootstrap.min",
  "r/bower_components/metisMenu/dist/metisMenu.min": "/server/r/bower_components/metisMenu/dist/metisMenu.min",
  "r/bower_components/select2/dist/js/select2": "/server/r/bower_components/select2/dist/js/select2",
  "r/static/js/hxz/hxz.ui": "/server/r/static/js/hxz/hxz.ui_0a7714d",
  "r/static/js/hxz/hxz": "/server/r/static/js/hxz/hxz_589b155",
  "r/bower_components/moment/min/moment-with-zh-cn.min": "/server/r/bower_components/moment/min/moment-with-zh-cn.min",
  "r/vendor/pagination/jquery.pagination": "/server/r/vendor/pagination/jquery.pagination",
  "r/bower_components/bootstrap-daterangepicker/daterangepicker": "/server/r/bower_components/bootstrap-daterangepicker/daterangepicker"
}});

  require(["r/bower_components/jquery/dist/jquery.min", "r/static/js/hxz/hxz", "r/static/js/alertify-config", "r/bower_components/moment/min/moment-with-zh-cn.min", "r/vendor/pagination/jquery.pagination", "r/bower_components/select2/dist/js/select2", "r/bower_components/bootstrap-daterangepicker/daterangepicker"], function ($, hxz, alertify, moment) {

    var pagination = {};
    var withdrawalsListFilter = {};

    var $startDate = $('#start-date');
    var $endDate = $('#end-date');

    var $startDateInput = $('#start-date input');

    var $endDateInput = $('#end-date input');

    var $startTime = $('#start-time');
    var $endTime = $('#end-time');

    var $withdrawalsOrganizer = $("#withdrawals-organizer");

    var $withdrawalsStatus = $("#withdrawals-status");

    function fetchOption() {

      hxz.doGet({url: hxz.RestApi.manageOrgOption}, function (data) {
        data.data.unshift({"id": 0, "text": "全部"});
        $("#withdrawals-organizer").select2({
          language: "zh-CN",
          placeholder: "请选择主办方",
          width: "200",
          data: data.data
        });
      });

      var statusData = [
        {"id": 999, "text": "全部"},
        {"id": 0, "text": "处理中"},
        {"id": 1, "text": "已转账"},
        {"id": 2, "text": "已拒绝"}
      ];

      $("#withdrawals-status").select2({
        language: "zh-CN",
        placeholder: "提现状态",
        width: "100",
        data: statusData
      });
    }


    /**
     *初始化分页控件 需要页面上包含<div id="pagination"></div>
     */
    function pagination(data, callback) {
      $('#pagination').pagination(count, {
        current_page: 0,
        items_per_page: 10,
        num_display_entries: 6,
        callback: function (page) {
          //模拟ajax去后端读取页数，获取数据并渲染列表的过程
          callback(page + 1);
        },
        load_first_page: false,
        prev_text: '上一页',
        next_text: '下一页'
      });

    }


    function fetchList(page) {
      var apiList = hxz.RestApi.manageWithdrawalsList;
      var data = {};
      data.page = page;
      if ($("#withdrawals-status").val() !== "" && $("#withdrawals-status").val() != "999") {
        data.status = $("#withdrawals-status").val();
      }

      if ($startTime.val() != "") {
        data.startTime = $startTime.val();
      }
      if ($endTime.val() != "") {
        data.endTime = $endTime.val();
      }
      if ($startTime.val() != "" && $endTime.val() != "") {
        if ($startTime.val() > $endTime.val() != "") {
          return alertify.log("检索的开始时间不能大于结束时间！");
        }
      }
      if ($withdrawalsOrganizer.val() != "" && $withdrawalsOrganizer.val() != "0") {
        data.organizerId = $withdrawalsOrganizer.val();
      }


      hxz.doGet({url: hxz.getUrlByfiterOption(apiList, data)}, function (data) {

        if (data.status == "0") {
          return alertify.log("系统错误");
        }

        render(data.data.dataList, page, data.data.count);
      });
    }


    function render(dataList, page, count) {
      var tpl = _.template($('#tpl-withdrawals-list-item').html());
      $("#withdrawals-list-body").html("");
      for (var i = 0; i < dataList.length; i++) {
        var _data = dataList[i];
        _data.index = hxz.pageIndex(i, page);
        _data.datetime = hxz.datetime;
        _data.withdrawalStatus = hxz.withdrawalStatus;

        $("#withdrawals-list-body").append(tpl(_data));
      }

      if (pagination) {
        pagination = false;
        $('#pagination').pagination(count, {
          current_page: 0,
          items_per_page: 10,
          num_display_entries: 6,
          callback: function (page_id) {
            //模拟ajax去后端读取页数，获取数据并渲染列表的过程
            fetchList(page_id + 1);
          },
          load_first_page: false,
          prev_text: '上一页',
          next_text: '下一页'
        });
      }
    }

    function event() {
      /*点击拒绝申请 触发的事件  弹出模态窗口*/
      $("#withdrawals-list-body").on("click", ".reject-apply", function () {
        var data = {
          applyId: $(this).data("code")
        };
        $("#reject-applyId").val(data.applyId);
        $("#reject-reason").val("");
        $("#reject-dialog").modal("show");
      });

      $("#withdrawals-list-body").on("click", ".apply-excel", function () {
        var data = {
          applyId: $(this).data("code")
        };
        window.open("/manage/apply-excel?applyId=" + data.applyId, "_blank")
      });


      /*提交拒绝申请*/
      $("#reject-submit").click(function () {
        console.info($("#reject-reason").val());
        console.info($("#reject-applyId").val());
        var data = {
          applyId: $("#reject-applyId").val(),
          reason: $("#reject-reason").val()
        };
        hxz.doPost({url: hxz.RestApi.manageRejectApply, data: data}, function (data) {
          if (data.status == "0") {
            return alertify.log(data.msg);
          } else {
            alertify.log("操作成功");
            $("#reject-dialog").modal("hide");
            fetchList(1);
          }
        });
      });

      $(".withdrawals-excel").on("click", function(){
        var applyId = $(this).attr("data-code");
        window.open("/manage/withdrawals/apply/orders/export?applyId=" + applyId);
      });

//      var pagination = true;

      $(".withdrawals-orders").on("click", function(){
        pagination = true;
        $(".withdrawals-excel").attr("data-code", $(this).attr("data-code"));
        var applyId = $(this).attr("data-code");
        fetchOrdersList(1, applyId);
      });

      function fetchOrdersList(page, applyId) {
        if (!page) {
          page = "1";
        }
        var data = {
          applyId: applyId,
          page   : page
        };

        hxz.doGet({url: hxz.getUrlByfiterOption(hxz.RestApi.manageWithdrawalsApplyOrders, data)}, function (data) {
          if (data.status == "0") {
            return alertify.log("订单正在努力生成中,请稍后再试");
          }
          var dataList = data.data.dataList;
          var dataCount = data.data.count;
          var tpl = _.template($("#tpl-apply-order-list-item").html());
          $("#applyOrders-list-body").html("");

          for (var i = 0; i < dataList.length; i++) {
            var _data = dataList[i];
            _data.datetime = hxz.datetime;
            $("#applyOrders-list-body").append(tpl(_data));
          }

          if (pagination) {
            pagination = true;

            $('#pagination-orders').pagination(dataCount, {
              current_page: 0,
              items_per_page: 10,
              num_display_entries: 6,
              callback: function (page_id) {
                console.log("~~~:" + page_id);
                //模拟ajax去后端读取页数，获取数据并渲染列表的过程
                fetchOrdersList(page_id + 1, applyId);
              },
              load_first_page: false,
              prev_text: '上一页',
              next_text: '下一页'
            });
          }

          $("#withdrawals-orders-dialog").modal("show");
        });
      }

      /*查看提现申请明细*/
      $("#withdrawals-list-body").on("click", ".detail-withdrawals", function () {
        var data = {
          applyId: $(this).data("code")
        };

        $('.withdrawals-orders').attr("data-code", $(this).data("code"));

        hxz.doGet({url: hxz.getUrlByfiterOption(hxz.RestApi.manageWithdrawalsApplyDetailList, data)}, function (data) {
          if (data.status == "0") {
            return alertify.log("系统错误");
          }
          var dataList = data.data;
          var tpl = _.template($('#tpl-apply-detail-list-item').html());
          $("#applyDetail-list-body").html("");
          for (var i = 0; i < dataList.length; i++) {
            var _data = dataList[i];
            _data.datetime = hxz.datetime;
            _data.episodeStatus = hxz.episodeStatus;


            $("#applyDetail-list-body").append(tpl(_data));
          }
        });
        $("#withdrawals-record-dialog").modal("show");
      });


      $("#withdrawals-filter").unbind("click").on("click", function () {
        pagination = true;
        fetchList(1);
      });

      moment.locale('zh-cn');
      var commDateConfig = {
        startDate: new Date(),
        locale: {
          format: 'YYYY年MM月DD日',
          separator: ' - ',
          applyLabel: '确定',
          cancelLabel: '关闭',
          weekLabel: 'W',
          customRangeLabel: 'Custom Range',
          daysOfWeek: moment.weekdaysMin(),
          monthNames: moment.monthsShort(),
          firstDay: moment.localeData().firstDayOfWeek()
        }
      };
      commDateConfig.singleDatePicker = true;

      $startDate.daterangepicker(commDateConfig, function (start, end, label) {
        $startDateInput.val(hxz.date(start));
        var sDate = new Date(start);
        $startTime.val(sDate.getTime());
      });
      var startDate = new Date();
      startDate.setDate(startDate.getDate() - 7);
      $startDateInput.val(hxz.date(startDate));
      $startTime.val(startDate.getTime());

      $endDate.daterangepicker(commDateConfig, function (start, end, label) {
        $endDateInput.val(hxz.date(start));
        // start 和 end 是moment对象
        var sDate = new Date(start);
        $endTime.val(sDate.getTime());
      });
      var endDate = new Date();
      endDate.setDate(endDate.getDate());
      $endDateInput.val(hxz.date(endDate));
      $endTime.val(endDate.getTime());

    }

    function pageInit() {
      pagination = true;
      fetchOption();
      $("#withdrawals-status").val("0").trigger("change");
      event();
      fetchList(1);
    }

    // 执行初始化
    pageInit();

  });


</script>
</body>
</html>